import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    aa:'ha',
    ab:'hb',
    count:1,
  },
  getters:{
    aaFn(state){
      return state.count*2;
    }
  },
  mutations: {
    //需是同步操作，所以更好追踪数据
    aboFn(state,payload){
      state.count+=payload.add;
    }
  },
  actions: {
    //支持异步操作
  },
  modules: {
    //模块分割..可抽离到一个js文件
    moduleA:{
      state:{}
      ,getters:{}
      ,mutations:{}
      ,actions:{}
    }
  }
})
